package reflect;

import java.lang.reflect.Method;

/**
 * 暴力反射：允许获得私有属性和私有方法
 */
public class ReflectDemo7 {
    public static void main(String[] args) throws Throwable {
        Class<?> cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        Method method = cls.getDeclaredMethod("heHe");
        method.setAccessible(true);
        method.invoke(obj);
        method.setAccessible(false);
    }
}
